﻿using Engine;
using Game;
namespace Mekiasm
{
    public class BatBoxWidget : BaseEnergyWidget
    {
        public ComponentEnergyMachine cptBaseEgy;
        public StackPanelWidget mStackCenter = new StackPanelWidget() { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center };

        public BatBoxWidget(ComponentEnergyMachine cpt_, ComponentMiner componentMiner, string displayName = "蓄电池") : base(componentMiner)
        {
            cptBaseEgy = cpt_;
            MekInventorySlotWidget inventory = new MekInventorySlotWidget() { Size = new Vector2(48, 48), Margin = new Vector2(0, 10) };
            inventory.AssignInventorySlot(cpt_, 0);
            inventory.ConfigSlotMode(componentMiner);
            mStackCenter.Children.Add(inventory);
            CanvasMain.Children.Add(mStackCenter);
            setTitle(displayName);

        }
        public override void Update()
        {
            float f = (float)cptBaseEgy.Power / cptBaseEgy.MaxPower;
            SetPowerProgress(f);
            SetLeftBottomMoreInfo($"当前:{ILibrary.FormatPower(cptBaseEgy.Power)}\n最大:{ILibrary.FormatPower(cptBaseEgy.MaxPower)}\n输入:{ILibrary.FormatPower(cptBaseEgy.InputPowerLimit)}\n输出:{ILibrary.FormatPower(cptBaseEgy.OutputPowerLimit)}");
        }
    }
}
